package com.zj.leetcode.easy.dynamicProgramming;

/**
 * @program: algorithm
 * @description:
 * 3 的幂
 * 326 power-of-three
 * @author: Zhang Bo
 * @create: 2022-05-06 11:12:29
 **/
public class PowerOfThree{
    public static void main(String[] args) {
        int n = 27;
        Solution solution = new PowerOfThree().new Solution();
        System.out.println(solution.isPowerOfThree(27));
    }
    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {


        public boolean isPowerOfThree(int n) {
            if(n < 3){
                return false;
            }

            int temp = n;

            while(temp > 3){
                if(temp % 3 != 0){
                    return false;
                }
                temp = temp / 3;
            }
            return true;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
